package com.yonyou.ucf.mdf.app.isvdxq.firstpart.appconfig.service;

import com.yonyou.ucf.mdf.app.isvdxq.firstpart.appconfig.entity.AppconfigEntity;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.appconfig.entity.TabInfoEntity;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.appconfig.mapper.AppconfigMapperImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AppconfigService {

    @Autowired
    private AppconfigMapperImpl appconfigMapper;

    public List<TabInfoEntity> SelectTabInfoById(String id) {
        return appconfigMapper.selectTabInfoById(id);
    }

    public AppconfigEntity SelectById(String id) {
        return appconfigMapper.selectById(id);
    }

    //查询应用配置信息
    public AppconfigEntity SelectByAppcode(String appcode,Integer appType, String tenantId){
        return appconfigMapper.SelectLastEntity(tenantId, appcode, appType);
    }

    public List<AppconfigEntity> SelectByIds(List<String> ids) {
        return appconfigMapper.selectByIds(ids);
    }

    public List<AppconfigEntity> SelectAll(String tenantId) {
        return appconfigMapper.selectAll(tenantId);
    }

    public AppconfigEntity SelectLastPrintConfig(String tenantId) {
        return appconfigMapper.SelectLastPrintConfig(tenantId);
    }

    public Integer InsertEntity(AppconfigEntity entity) {
        return appconfigMapper.insert(entity);
    }

    public Integer UpdateEntity(AppconfigEntity entity) {
        return appconfigMapper.updateByPrimaryKey(entity);
    }

    public Integer DeleteById(Long id) {
        return appconfigMapper.deleteByPrimaryKey(id);
    }

    public Integer DeleteByIds(List<Long> ids) {
        return appconfigMapper.deleteByPrimaryKeys(ids);
    }

    //新增并更新
    public Integer InsertBatch(List<AppconfigEntity> list) {
        if (list.size() == 0) return 0;
        long start = System.currentTimeMillis();
        int res = appconfigMapper.insertBatch(list);
        long end = System.currentTimeMillis();
        System.out.println("---------------" + (start - end) + "---------------");
        return res;
    }
}
